<?php

namespace app\common\model;

use think\Model;

/**
 *
 */
class CrontabNew Extends Model
{

    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    // 追加属性
    protected $append = [
    ];


    protected function initialize()
    {
        //需要调用`Model`的`initialize`方法
        parent::initialize();
        //TODO:自定义的初始化
    }


    /**
     * 返回统计所有订单利润
     * @return float 返回总订单利润
     */
    public function OrderProfit(){
       try{
           $ShopOrderModel=new \app\admin\model\Litestoreshoporder();
           $data=$ShopOrderModel
               ->whereTime('createtime', 'yesterday')
               ->sum('Payment_ph');
       }catch (\Exception $e){
            return 0;
       }
       return $data;

    }

    /**
     * 查询提出去的利润总统计
     * @return float 返回统计
     */
    public function MoneyTotal(){
       try{
           $MoneyModel=new UserMoneyLog();
           $where['money_type']=array('in',array('1','2','3'));
           $data=$MoneyModel
               ->whereTime('createtime', 'yesterday')
               ->where($where)
               ->sum('money');
       }catch (\Exception $e){
           return 0;
       }
       return $data;
    }

    public function ContributionTotal(){
        try{
            $MoneyModel=new UserMoneyLog();
            $data=$MoneyModel
                ->whereTime('createtime', 'yesterday')
                ->where(['money_type'=>8])
                ->sum('money');
        }catch (\Exception $e){

        }
        return $data;
    }



}
